import { ACTION_TYPES } from 'utils/constant';
const initialState = {
    loading: false,
    members: []
}


export default function group(state = initialState, action) {
    switch (action.type) {
        case ACTION_TYPES.GROUP_MEMBERS_REQUEST: 
            return ({
                ...state, 
                          
               
            })
        case ACTION_TYPES.GROUP_MEMBERS_SUCCESS:
            return ({
                ...state,
                members: action.members
               
            })
        case ACTION_TYPES.GROUP_MEMBERS_FAIL:
            return ({
                ...state,
               
            })
        case ACTION_TYPES.GROUP_QUIT_REQUEST:
            return ({
                ...state
            })
        case ACTION_TYPES.GROUP_QUIT_SUCCESS:
            const members = state.members;
            const index = members.findIndex(action.id);
            
            if (index > -1) {
                members.splice(index, 1);
            }
            return ({
                ...state,
                members
            })
        case ACTION_TYPES.GROUP_QUIT_FAIL:
            return ({
                ...state
            })
        default:
            return state;
    }
}